<%@page import="fr.uniscol.model.BaseAnneeScolaire"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<script type="text/javascript">
    $(document).ready(function(){
       
    });
    
    function deleteEnseignant(enseignantId, identite){
        $(".modal-body").html("Supprimer l'enseignant " + identite + " ?");
        $("#btnAnnuler").html("Annuler");
        $("#btnValider").html("Supprimer");
        
        $("#btnValider").click(function(){
           location='enseignant.delete?enseignantid=' + enseignantId; 
        });
        
        $("#confirmDeleteEnseignant").modal("show");
    }
    
</script>

<div class="container-fluid">
	<div class="row">
		<div class="col-md-10">
			<h4>Enseignants</h4>
			<table class="table table-striped table-hover">
				<thead>
					<tr>
						<th>ID</th>
						<th>Nom</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
				<c:forEach items="${enseignants}" var="ens">
					<tr>
						<td>${ens.id}</td>
						<td>${ens.nom} ${ens.prenom}</td>
						<td class="buttons">
							<button type="button" class="btn btn-primary btn-xs" onClick="javascript:location='<c:url value="enseignant.edit?enseignantid=${ens.id}" />'">Modifier</button>
							<button type="button" class="btn btn-default btn-xs" onClick="javascript:deleteEnseignant(${ens.id}, '${ens.prenom} ${ens.nom}')">Supprimer</button>
						</td>
					</tr>
				</c:forEach>
				</tbody>
			</table>
		</div>
	</div>
</div>

<c:set var="modalId" value="confirmDeleteEnseignant" scope="request" />
<c:set var="modalTitle" value="Supprimer un enseignant" scope="request" />
<jsp:include page="../components/modal.jsp" flush="true" />